package com.bw.day03.quan

import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.LinearLayoutManager
import com.bw.base.net.mvvm.BaseFragment
import com.bw.day03.R
import com.bw.day03.adapter.MyQuanAdapter
import com.bw.day03.databinding.FragmentUseBinding


class UseFragment : BaseFragment<FragmentUseBinding, QuanViewModel>() {
    lateinit var myQuanAdapter: MyQuanAdapter
    override fun initView() {
        myQuanAdapter= MyQuanAdapter()
        binding.quan.adapter=myQuanAdapter
        binding.quan.layoutManager= LinearLayoutManager(context)
        viewModel.use("2","1","usable")

    }

    override fun initData() {
        viewModel.useSuccess.observe(this){
            if (it.code==200){
                myQuanAdapter.data.clear()
                myQuanAdapter.data.addAll(it.data.list)
                myQuanAdapter.notifyDataSetChanged()
            }
        }

    }

    override fun getViewModel(): Class<QuanViewModel> = QuanViewModel::class.java

    override fun getLayoutId(): Int = R.layout.fragment_use


}